﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
using System.Data;
public partial class NewsList : System.Web.UI.Page
{
    int ToatalCountRecord;//总记录数 
    int PageItem = 15;
    //private System.ComponentModel.BackgroundWorker backgroundWorker1;//每页显示的条数 
    int CurrentPage = 1;//当前页数 
    public string Top1News = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["page"] != null)
            {
                if (!Int32.TryParse(Request.QueryString["page"].ToString(), out CurrentPage))
                {

                    //bind();
                    Response.Redirect("index.aspx");
                }
                if (Int32.Parse(Request.QueryString["page"].ToString()) == 1)
                {

                }
            }
            else
            {
                CurrentPage = 1;

            }
            bind();
        }
    }
    private void bind()
    {
        //新闻显示
        News getall = new News();
        OleDbDataAdapter da = getall.GetNewsAll();
        DataSet ds = new DataSet();
        int startRecord = (CurrentPage - 1) * PageItem;
        da.Fill(ds, startRecord, PageItem, "a");
        this.ListView1.DataSource = ds.Tables["a"].DefaultView;
        this.ListView1.DataBind();
        ToatalCountRecord = getall.GetNewsCount();
        PageInfo.InnerHtml = Pagecode.BuildPages(ToatalCountRecord, PageItem, CurrentPage, 5, 0, 0, "NewsList.aspx?page=", "", "");

    }
}